using System.Collections;
using UnityEngine;

public class MenuLoad : MonoBehaviour
{
	public static int curprogress = 100;

	public static int tipsindex;

	public UILabel percentlabel;

	public UILabel tipslabel;

	public UISprite slidersp;

	public Transform thumbtra;

	public UISprite bgsp;

	private float planeendx;

	private float ratio;

	public bool lightmoveflag;

	public Transform lighttra;

	public UISprite lightsp;

	public float speed;

	public float startx;

	public float endx;

	public void enable()
	{
		lightsp.enabled = false;
		tipslabel.text = "提示:" + GlobalInf.tips[tipsindex];
		NGUITools.SetActive(base.gameObject, state: true);
		StartCoroutine("lightmove");
	}

	private IEnumerator lightmove()
	{
		for (float i = 0f; i < 0.5f; i += Time.deltaTime)
		{
			yield return 0;
		}
		lightmoveflag = true;
		startx *= GlobalInf.screenRatioWidth / 800f;
		endx *= GlobalInf.screenRatioWidth / 800f;
		lighttra.localPosition = new Vector3(startx, 30f, 0f);
		lightsp.enabled = true;
	}

	private void Update()
	{
		curprogress++;
		if (curprogress >= 100)
		{
			curprogress = 100;
			GlobalInf.loading_over = true;
			disable();
		}
		percentlabel.text = curprogress + "%";
		slidersp.fillAmount = (float)curprogress / 100f;
		ratio = -0.5f + (float)curprogress / 100f + 0.05f;
		if (ratio > 0.5f)
		{
			ratio = 0.5f;
		}
		planeendx = (float)bgsp.width * ratio;
		thumbtra.localPosition = new Vector3(planeendx, 0f, 0f);
		if (lightmoveflag)
		{
			lighttra.Translate(speed * Time.deltaTime, 0f, 0f, Space.Self);
			float num = endx;
			Vector3 localPosition = lighttra.localPosition;
			if (num - localPosition.x < 1f)
			{
				lightmoveflag = false;
				lightsp.enabled = false;
			}
		}
	}

	public void disable()
	{
		MenuBackController.instance.BackMenuUIstate();
		MenuUIController.instance.firstshow();
		NGUITools.SetActive(base.gameObject, state: false);
		lightmoveflag = false;
	}
}
